// https://leetcode.cn/problems/my-calendar-i/
// Created by ade on 2022/7/19.
//
#include <iostream>
#include <vector>
#include <map>


using namespace std;

class MyCalendar {
public:
    MyCalendar() {

    }

    vector<pair<int, int>> booked;

    /*
     * [47,50],true
     * [33,41],true
     * [39,45],false
     * [33,42],false
     * [25,32],true
     * [26,35],false
     * [19,25],false  应该是true
     * [3,8],true
     * [8,13],true
     * [18,27],false
     * */

    bool book(int start, int end) {
        for(auto &i : booked){
            // if(start >= i.first && start < i.second || end > i.first && end <= i.second) 这种写法是错误的
            if(i.second > start  && i.first < end){
                return false;
            }
        }
        booked.emplace_back(start, end);
        return true;
    }
};

int main() {
    MyCalendarTwo so;
    vector <pair<int, int>> res;
    res = {{26, 35},
           {26, 32},
           {34, 36},
           {18, 26},
           {40, 45},
           {19, 26},
           {48, 50},
           {1,  6},
           {46, 50},
           {11, 18}};
    for (auto i : res) {
        if (so.book(i.first, i.second)) {
            cout << "true," << endl;
        } else {
            cout << "false," << endl;
        }
    }
    return 0;
}